<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head><script type="text/javascript" src="/utils/scripts/flat-ui.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><link rel="shortcut icon" href="/utils/image/favicon.ico" type="image/x-icon" />
		<meta charset="UTF-8">
		<title>学生信息管理系统</title>
		<!-- Loading Bootstrap -->
		<link href="/utils/css/vendor/bootstrap.min.css" rel="stylesheet">
		<!-- Loading Flat UI Pro -->
		<link href="/utils/css/flat-ui.css" rel="stylesheet">
		<!-- Loading Flat UI JS -->
		<script type="text/javascript" src="/utils/scripts/flat-ui.min.js"></script>	

	   <script type='text/javascript' src='/utils/scripts/particles.js'></script><link href="/utils/css/animate.css" rel="stylesheet">
		<script type="text/javascript" src="/utils/js/jquery-3.3.1.min.js"></script>
<%--		<script type="text/javascript">--%>
<%--			$(function () {--%>
<%--				// alert("saa")--%>
<%--				$("#Teacher_form").ajaxForm(function (data) {--%>
<%--					alert(data)--%>
<%--				})--%>
<%--			})--%>
<%--		</script>--%>
	   <script type="text/javascript">

		   //检查tid是否合法
		   function checkTid() {
		   	   //1.获取tid
			   var tid=document.getElementById("tid").value;
			   if(tid!=""){
			   	  //tid有值
				  //发送一个Ajax异步请求，去服务器后台校验tid是否存在
				  //1.创建一个异步对象
				  var xhr=new XMLHttpRequest();
				  //2.设置异步回调
				  xhr.onreadystatechange=function () {
				  	 //异步对象请求结束 4表示请求结束   200表示OK
				  	 if(xhr.readyState==4&&xhr.status==200){
				  	 	//服务器反馈的结果！
				  	 	var result=xhr.responseText;
				  	 	//alert(result);
						 if(result=="true"){
							 document.getElementById("counttid").innerText="教师编号已存在!";
							 document.getElementById("counttid").style.color="red";
						 }else{
							 document.getElementById("counttid").innerText="教师编号可用!";
							 document.getElementById("counttid").style.color="green";
						 }
					 }
				  };
				  //3.请求地址和参数  /teacherServlet.do?flag=checktid&tid=8888
				  var url="/teacherServlet.do?flag=checktid&tid="+tid;
				  //4.发送Ajax  get请求
				  xhr.open("get",url,true);  // true表示异步请求
				  xhr.send();
			   }else{
			   	  document.getElementById("counttid").innerText="教师编号不能为空!";
				  document.getElementById("counttid").style.color="red";
			   }
		   }

	   </script>

	</head>
	
	<body><div id="particles-js"><canvas class="particles-js-canvas-el" width="1322" height="774" style="width: 100%; height: 100%;"></canvas></div>
	<jsp:include page="adminLeft.jsp" />
	<div class="container">
		<div class="row">
			<div class="col-md-6">
				<h5>添加教师</h5>
				<form id="Teacher_form" action="/teacherServlet.do?flag=add" method="post">
					<h6>教师编号</h6>

						<input type="text" name="tid" id="tid" class="form-control" onblur="checkTid();" oninput = "value=value.replace(/[^\d]/g,'')" maxlength="5"></input>

						<span id="counttid" style="color: #ff0000;"></span>
					<h6>姓名</h6>
						<input type="text" name="tname" class="form-control" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')" maxlength="4"></input>
						<h6>密&nbsp;&nbsp;码</h6>
						<input type="password" name="tpassword" class="form-control" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" maxlength="16"></input>
						<h6>性别</h6>
						
						<label class="radio" for="radio1">
                  		<input type="radio" name="tsex" value="男" checked id="radio1" data-toggle="radio" class="custom-radio">
               			<span class="icons">
               				<span class="icon-unchecked"></span>
               				<span class="icon-checked"></span>
               			</span>
               			<font style="vertical-align: inherit;">
               				<font style="vertical-align: inherit;">
               			 		男
               				</font>
               			</font>
               		</label>
               		
               		<label class="radio" for="radio2">
                  		<input type="radio" name="tsex" value="女" id="radio2" data-toggle="radio" class="custom-radio">
               			<span class="icons">
               				<span class="icon-unchecked"></span>
               				<span class="icon-checked"></span>
               			</span>
               			<font style="vertical-align: inherit;">
               				<font style="vertical-align: inherit;">
               			 		女
               				</font>
               			</font>
               		</label>
				
						<h6>个人简介</h6>
						<textarea name="introduction" cols="20" rows="6" class="form-control"></textarea>
						<input type="submit" value="添加" class="btn btn-primary btn-wide login-btn" style="margin-top:2rem"/>
				</form>
			</div>
		</div>	
	</div>
	<script type="text/javascript" src="/utils/scripts/flat-ui.js"></script><script src="/utils/scripts/bganimation.js"></script></body>
</html>